#define _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>
#include <math.h>

int main() {
    int n = 0;
    scanf("%d", &n);
    long long int sum = 0;
    int x = 0;
    for (x = 0; n != 0; sum += (n % 6) * pow(10, x), x++, n /= 6);

    printf("%lld", sum);

    return 0;
}